import React,{Component} from 'react';
import LoginTab from "./login/login";
import PubSub from "pubsub-js";
import {Container} from "semantic-ui-react";
import WalletTab from "./wallet/wallet";


class App extends Component{

    state = {
        wallet:{},
        loginStatus:false,
    }

    componentDidMount() {
        PubSub.subscribe("onLoginSuccessfully",this.onLoginSuccessfully)

    }

    //收到订阅信息的处理
    onLoginSuccessfully = (eventMsg,wallet)=>{
        this.setState({wallet:wallet,loginStatus:true})
    }



    render() {
        let {wallet,loginStatus} = this.state
        let content = loginStatus ?<WalletTab wallet = {wallet} />:<LoginTab />
        return(
            <Container>
                {content}
            </Container>
        )
  }
  //   render() {
  //       return(
  //           <CardExampleCard />
  //       )
  //   }
}


export default App;

